/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
const toUpperStr = (str: string) => str.toUpperCase();
type AccessUserInfo = USER.CurrentUser & { hasMenuIds: string[] };
export default function access(initialState: { currentUser?: AccessUserInfo } | undefined) {
  const { currentUser } = initialState ?? {};
  return {
    normalRouteFilter: (route: any) => {
      return !!currentUser?.authMenuTree[toUpperStr(route.path)];
    },
  };
}
